// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
       // brush: cc.Node,
    },

    onLoad() {
    },

    start() {
        this.drawInfo = {
            "lineWidth": 5,
            "color": "BLACK",
            "x0": 0,
            "y0": 0,
            "x1": 0,
            "y1": 0,
        }

        this.drawInfo.lineWidth = 5

        // this.node.on('touchstart', this.onTouchStart, this);
        // this.node.on('touchmove', this.onTouchMove, this);
    },

    onTouchStart(event) {
        // 设置笔刷起始位置
        // let pos = this.node.convertToNodeSpaceAR(event.getLocation());
        // this.drawInfo.x0 = pos.x
        // this.drawInfo.y0 = pos.y
    },

    onTouchMove(event) {
        // if (this.brush == null) {
        //     return
        // }

        // let pos = this.node.convertToNodeSpaceAR(event.getLocation());
        // console.log("onTouchMove| pos.x:", pos.x, "gpos.y:", pos.y)

        // this.drawInfo.x1 = pos.x
        // this.drawInfo.y1 = pos.y

        // this.brush.getComponent('Brush').doDraw(this.drawInfo.x0, this.drawInfo.y0, this.drawInfo.x1, this.drawInfo.y1, this.drawInfo.color, this.drawInfo.lineWidth);

        // // 更新起始位置
        // this.drawInfo.x0 = this.drawInfo.x1
        // this.drawInfo.y0 = this.drawInfo.y1
    },

    // update (dt) {},
});
